fileFolder=fullfile('D:\figure');   %fig文件所在文件夹
 
dirOutput=dir(fullfile(fileFolder, '*.fig'));
 
fileNames={dirOutput.name}';
 
len = length(fileNames)
 
for i = 1:len
    dir = fullfile('D:\figure' , fileNames{i})     %fig文件所在文件夹
    h = openfig(dir)
    name = erase(fileNames{i},'.fig')
    saveas(strcat(name, '.png') , 'h')
end